package com.letoken.platform.job.configuration;

import com.letoken.platform.job.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version 1.0
 * @author： txx
 * @date： 2021-08-28 16:43
 */
@Configuration
public class RabbitTopicExchangeConfiguration {



    @Bean
    public Queue queueMsg() {
        return new Queue(RabbitConstant.QUEUE_WS_MSG);
    }

    @Bean
    TopicExchange exchange() {
        return new TopicExchange(RabbitConstant.TOPIC_EXCHANGE_WS_MSG);
    }

    /**
     * 绑定消息信道
     *
     * @return
     */
    @Bean
    Binding bindingExchangeMessage() {
        return BindingBuilder.bind(this.queueMsg()).to(this.exchange()).with(RabbitConstant.QUEUE_WS_MSG);
    }

}
